﻿using Microsoft.Graphics.Canvas;
using System;
using System.Collections.Generic;

using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Windows.UI;
using 纸片人.Shaders;

namespace 纸片人.InfoDataFolder
{
    public class LayerBitmapData
    {

        public CanvasBitmap oneBitmap;
        public CanvasBitmap twoBitmap;

        public int oneWidth, oneHeight;
        public int twoWidth, twoHeight;
        public Color[] oneColors;
        public Color[] twoColors;


        public byte[] oneShaderCode;
        public byte[] twoShaderCode;
        public byte[] threeShaderCode;

        public async Task SelectOneBitmapAsync(CanvasDevice device = null)
        {
            if (device == null)
                device = CanvasDevice.GetSharedDevice();

            oneBitmap = await Function.SelectImageAsync(device);
            if (oneBitmap is null) return;
            oneWidth = (int)oneBitmap.SizeInPixels.Width;
            oneHeight = (int)oneBitmap.SizeInPixels.Height;
            oneColors = oneBitmap.GetPixelColors();

        }

        public async Task SelectTwoBitmapAsync(CanvasDevice device = null)
        {
            if (device == null)
                device = CanvasDevice.GetSharedDevice();
            twoBitmap = await Function.SelectImageAsync(device);
            if (twoBitmap is null) return;
            twoColors = twoBitmap.GetPixelColors();
            twoWidth = (int)twoBitmap.SizeInPixels.Width;
            twoHeight = (int)twoBitmap.SizeInPixels.Height;
        }

        public async Task LoadOneShadeCodeAsync(ShaderType type)
        {
            oneShaderCode = await type.LoadAsync();
        }

        public async Task LoadTwoShadeCodeAsync(ShaderType type)
        {
            twoShaderCode = await type.LoadAsync();
        }

        public async Task LoadThreeShadeCodeAsync(ShaderType type)
        {
            threeShaderCode = await type.LoadAsync();
        }
    }
}
